package com.charley.icloud.wrapper;

import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;

import java.util.Map;

/**
 * ObjectWrapperFactory 用于对对象进行包装后处理，在mybatis中用于对结果对象的处理
 * */
public class MapWrapperFactory implements ObjectWrapperFactory {

    /**
     * 判断是否满足条件
     * */
    @Override
    public boolean hasWrapperFor(Object object) {
        return object instanceof Map;
    }

    /**
     * 获取ObjectWrapper对象
     * */
    @SuppressWarnings("unchecked")
    @Override
    public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
        return new MapKeyUpperWrapper(metaObject,(Map<String,Object>)object);
    }
}
